function bindElements(){
	$("input[id^='SysTermDate']").datepicker({showOn: "button",buttonImage: $("#Images").val() + "office-calendar.png", buttonImageOnly: true});
	$("input[id^='TermDate']").datepicker({showOn: "button",buttonImage: $("#Images").val() + "office-calendar.png", buttonImageOnly: true});
	$("input[id^='TermReqID']").click(function(){
		var parentRow = $(this).parent().parent();
		var thisTermReqID = parentRow[0].id;
		var thisTermDate = $("#TermDate" + thisTermReqID).val();
		var thisSysTermDate = $("#SysTermDate" + thisTermReqID).val();
		var obj = {TermReqID: thisTermReqID, TermDate: thisTermDate, SysTermDate: thisSysTermDate};
		var api = $("#FormAction").val();
		submitForm(obj, api);
	});
}


//ajax POST to add to database.
function submitForm(obj, api){
	$.ajax({
		type:'POST', url:api, dataType: 'json', async: true, data: obj,
		success: function() { return false; },
		complete: function(){ document.location.href = 'Step3-TermSchedule.cfm'; },
		error: function(){ return false; }
	});
}


$(function(){
	bindElements();
});